package dead;

/**
 * @author lcx
 *
 *这个不是死锁，因为只有一个对象
 */
public class FakeDeadLock implements Runnable
{
    boolean flag=false;
    public synchronized void m1()
    {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        System.out.println("waiting 2");
        m2();
    }

    public synchronized void m2()
    {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("waiting 1");
        m1();
    }


    public void run() {
        m1();
//        m2();
    }

    public static void main(String[] args) {
    	FakeDeadLock dl=new FakeDeadLock();
        Thread thd1=new Thread(dl);
        Thread thd2=new Thread(dl);
        thd1.start();
        dl.m2();
    }
}

